﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using SEOBlog.Entities.Entities;
using SEOBlog.Services.Repositories;

namespace SEOBlog.Services
{
    public class PagesService
    {
        private PagesRepository _repository;

        public PagesService()
        {
            _repository = new PagesRepository(ConfigurationManager.ConnectionStrings["Mongo.SeoBlog"].ConnectionString);
        }

        public List<Page> GetAllPages()
        {
            return _repository.All().ToList();
        }

        public Page GetByFriendlyUrl(string uri)
        {
            return _repository.All().Where(x => x.FriendlyUrl == uri).FirstOrDefault();
        }

        public bool Create(Page page)
        {
            return _repository.Save(page);
        }
    }
}
